package com.leeon.generics;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class Generators {
	/*
	public static <T> Collection<T> fill(Collection<T> coll,Generator<T> gen,int n){
		for(int i = 0; i < n; i++){
			coll.add(gen.next());
		}
		return coll;
	}*/
	
	public static <T,C extends Collection<T>> C fill(C c,Generator<T> gen,int n){
		for (int i = 0; i < n; i++) {
			c.add(gen.next());
		}
		return c;
	}
	
	public static void main(String[] args){
		Collection<Coffee> coffees = fill(new ArrayList<Coffee>(), 
				new CoffeeGenerator(), 4);
		for (Coffee coffee : coffees) {
			System.out.println(coffee);
		}
		List<Integer> number = fill(new ArrayList<Integer>(), 
				new Fibonacci(), 4);
		for (Integer integer : number) {
			System.out.print("  " + integer);
		}
	}
}
